<?php

class User
{
	protected $_id;
	protected $_login;
	protected $_password;
	protected $_gender;
	protected $_firstName;
	protected $_lastName;
	protected $_mail;
	protected $_tel;
	
	public function __construct(array $donnees)
	{
		$this->hydrate($donnees);
	}
		
	public function hydrate(array $donnees)
	{
		foreach($donnees as $key => $value)
		{
			$method = 'set'. ucfirst($key);
			if(method_exists($this, $method))
			{
				$this->$method($value);
			}
		}
	}
	
	public function id(){ return $this->_id; }
	public function login(){ return $this->_login; }
	public function password(){ return $this->_password; }
	public function gender(){ return $this->_gender; }
	public function firstName(){ return $this->_firstName; }
	public function lastName(){ return $this->_lastName; }
	public function mail(){ return $this->_mail; }
	public function tel(){ return $this->_tel; }
	
	public function setId($id)
	{
		$id = (int) $id;
		if(is_int($id))
		{
			$this->_id = $id;
		}
	}
	public function setLogin($login)
	{
		$login = (string) $login;
		if(is_string($login))
		{
			$this->_login = $login;
		}
	}
	public function setPassword($password)
	{
		$password = (string) $password;
		if(is_string($password))
		{
			$this->_password = $password;
		}
	}
	public function setGender($gender)
	{
		$gender = (string) $gender;
		if(is_string($gender))
		{
			$this->_gender = $gender;
		}
	}
	public function setFirstName($firstName)
	{
		$firstName = (string) $firstName;
		if(is_string($firstName))
		{
			$this->_firstName = $firstName;
		}
	}
	public function setLastName($lastName)
	{
		$lastName = (string) $lastName;
		if(is_string($lastName))
		{
			$this->_lastName = $lastName;
		}
	}
	public function setMail($mail)
	{
		$mail = (string) $mail;
		if(is_string($mail))
		{
			$this->_mail = $mail;
		}
	}
	public function setTel($tel)
	{
		$tel = (string) $tel;
		if(is_string($tel))
		{
			$this->_tel = $tel;
		}
	}
	
}